//package com.example.kuaizu.newfunction;
//
//import jakarta.mail.MessagingException;
//import jakarta.mail.internet.MimeMessage;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.mail.javamail.JavaMailSender;
//import org.springframework.mail.javamail.MimeMessageHelper;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * @author xiaokai
// * @version 1.0
// */
//@RestController
//@RequestMapping(path = "/email", produces = "application/json;charset=utf-8")
//public class NewEmalFunction {
//
//
//    private final JavaMailSender mailSender;
//    //发件人邮箱设置
//    private final EmailProperties emailProperties;
//
//    @Autowired
//    public NewEmalFunction(JavaMailSender mailSender, EmailProperties emailProperties) {
//        this.mailSender = mailSender;
//        this.emailProperties = emailProperties;
//    }
//
//    //@GetMapping("/sendEmail")
//    public Map<String, Object> sendEmail(String data) throws MessagingException {
//
//        MimeMessage message = mailSender.createMimeMessage();//创建邮件对象
//
//        MimeMessageHelper helper = new MimeMessageHelper(message);//创建邮件助手对象
//
//        helper.setFrom(emailProperties.getFrom()); // 设置发送邮箱，这个邮箱要和配置文件里设置的username一致
//        helper.setTo("3097405584@qq.com"); // 设置接收邮箱，发送方和接收方可以是同一个邮箱
//        helper.setText(data);//设置邮件内容
//
//        mailSender.send(message);//发送邮件
//
//        Map<String, Object> resultMap = new HashMap<>();
//
//        resultMap.put("code", 200);
//        resultMap.put("data", null);
//        resultMap.put("success", true);
//        resultMap.put("message", "发送成功");
//
//        return resultMap;
//    }
//
//
//}
